<?php

class multitender_model_detail extends multitender_model {

    function get($id) {
        // LEFT JOIN вместо , (запятая), ибо type_id == NULL
        $item = $this->db->GetRow(
                "SELECT item.*, type.name as type_name, " .
                "  site.id as site_id, " .
                "  site.name as site_name, " .
                "  site.detail_link as site_detail_link, " .
                "  site.doc_link as site_doc_link, " .
                "  site.url as site_url, " .
                "  site.desc as site_desc, " .
                "  region.name as region_name, " .
                "  region.timezone as region_tz " .
                "FROM item " .
                "LEFT JOIN type ON type.id = item.type_id " .
                "LEFT JOIN region ON region.id = item.region_id " .
                "INNER JOIN site ON site.id = item.site_id " .
                "WHERE item.id = $id"
        );
        return $item;
    }
    
    function getDetail($id) {
        if (!$id) { return false; } 
        return $this->db->GetRow("SELECT * FROM detail WHERE id = ?", array($id));
    }
    
    function getDoc($id) {
        if (!$id) { return false; } 
        return $this->db->GetArray("SELECT * FROM doc WHERE item_id = ? ORDER BY id DESC", array($id));
    }

}